package com.winning.pmph.config;

import com.winning.pmph.interceptor.KmsCacheInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class KmsInterceptorConfig implements WebMvcConfigurer {
    @Resource
    private KmsCacheInterceptor kmsCacheInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(kmsCacheInterceptor)
                .addPathPatterns("/pmph/action/**")
                .excludePathPatterns("/pmph/action/pmph/**",
                        "/pmph/action/increaseQrCode/updateScanCount",
                        "/pmph/action/file/getFile",
                        "/pmph/action/audio/play",
                        "/pmph/action/video/play",
                        "/pmph/action/knowledge/selectReleasedKnowledgeDetail");
    }
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/public/**")
                .addResourceLocations("classpath:/public/");
    }
}
